//
//  SettingButton.m
//  LimitFree
//
//  Created by qianfeng on 15/8/26.
//  Copyright (c) 2015年 Hailong.wang. All rights reserved.
//

#import "SettingButton.h"
#import "UIView+Addition.h"

@implementation SettingButton
//返回一个自定义Button
+(SettingButton*)createButtonWithTitle:(NSString*)title frame:(CGRect)frame image:(NSString*)image clicked:(NSString*)clicked target:(id)target selector:(SEL)selector{
    SettingButton* button=[[SettingButton alloc]initWithFrame:frame];
    
    [button setTitle:title image:image clicked:clicked];
    
    [button addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    return button;
}
-(id)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        [self createButton];
    }
    return self;
}
-(void)createButton{
    UIImageView* image=[[UIImageView alloc]initWithFrame:CGRectMake(5,5,57, 57)];
    //[image setYOffset:5];
    image.userInteractionEnabled=YES;
    image.tag=1508;
    [self addSubview:image];
    
    UILabel*label=[Factory createLabelWithTitle:nil frame:CGRectMake(0,image.bottom+5, self.width, LeftDistance*2) textColor:[UIColor blackColor] fontSize:14.f];
    label.textAlignment=NSTextAlignmentCenter;
    label.tag=1509;
    [self addSubview:label];
}
-(void)setTitle:(NSString *)title image:(NSString*)image clicked:(NSString*)clicked{
    UILabel *label=(UILabel*)[self viewWithTag:1509];
    label.text=title;
    
    UIImageView* imageView=(UIImageView*)[self viewWithTag:1508];
    imageView.image=[UIImage imageNamed:image];
}
@end
